<?php 
function downURI($url)
{
	set_time_limit(0);
	$fp=fopen($url,"r");

	$filename = ROOT_PATH . '/update.zip';
	if (file_exists($filename)) {
		@unlink($filename);
	}
	$handle=fopen($filename,"a");
	while(!feof($fp)){//测试文件指针是否到了文件结束的位置 
        $content=fread($fp,1024); 
        fwrite($handle,$content); 
    }
    fclose($fp);  
    fclose($handle);

	
	loadLib('pclzip');
	// 解压安装文件
	$zip = new PclZip($filename);
	$zip->extract(PCLZIP_OPT_PATH, ROOT_PATH);
	if (file_exists($filename)) {
		@unlink($filename);
	}

}

function loadLib($file)
{
	include ROOT_PATH.'/setup/lib/'.$file.'.lib.php';
}

?>